package packml;

import java.text.*;

public class Clock1 {
    private int Hours1;
    private int Minutes1;
    private int Seconds1;
    
	
	public Clock1(){
		Hours1 = 0;
		Minutes1 = 0;
		Seconds1 = 0;
	}
	
	
	public Clock1(int Sec){
		if(Sec > 60){
			Hours1 = 0;
			Minutes1 = 0;
			while(Sec >= 60){
				increaseMinutes();
				Sec -= 60;
			}
			Seconds1 = Sec;
		}else{
			Hours1 = 0;
			Minutes1= 0;
			Seconds1 = Sec;
		}
	}

	
	public String displayTime(){
		
	
		MessageFormat mf = new MessageFormat("{0}:{1}:{2}");
		DecimalFormat df = new DecimalFormat("00");
		Object[] objs = {df.format(Hours1), df.format(Minutes1), df.format(Seconds1)}; 
		return mf.format(objs);
		
		// Java 1.5 and Above Equivalent
		//return String.format("%02d:%02d:%02d", Hours, Minutes, Seconds);
	}


	public void increaseSeconds(){
		Seconds1++;
		if(Seconds1>= 60){
			Seconds1 = 0;
			increaseMinutes();
		}
	}

	
	public void increaseMinutes(){
		Minutes1++;
		if(Minutes1 >= 60){
			Minutes1 = 0;
			increaseHours();
		}
	}

	
	public void increaseHours(){
		Hours1++;
		

		if(Hours1 >= 99){
			Hours1 = 0;
		}
	}
	
	public void resetClock(){

		Hours1 = 0;
		
		Minutes1 = 0;
		
		Seconds1 = 0;
	
	}
}

